Skip to content

[Server] Send every response through TransportInterface::send() - #562

Merged
chr-hertel merged 6 commits into
modelcontextprotocol:mainfrom
chr-hertel:inline-responses-follow-up
Oct 10, 2026
Merged

chr-hertel merged 6 commits into
modelcontextprotocol:mainfrom
chr-hertel:inline-responses-follow-up

Conversation

@chr-hertel

Copy link
Copy Markdown
Member

Follow-up to #535.

  • Drops InlineResponseTransportInterface - every response goes through TransportInterface::send(), the session queue only carries server-initiated requests & notifications
  • A session that fails to save no longer adds an internal error to the responses already sent
  • [BC Break] a custom transport now gets every response via send(), see CHANGELOG

cc @guillaume-sainthillier WDYT?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Suspended exchanges mishandle save failures, and their final responses still bypass the documented universal send() path.

2 open findings
What changed in this PR

Routes normal server responses directly through transports instead of shared session queues.

Changes:

  • Removes the inline-response marker interface.
  • Updates HTTP response collection, protocol behavior, tests, and changelog.
  • Suppresses session-save errors after responses are sent.
File Description
src/​Server/​Protocol.php Sends responses directly and handles save failures.
src/​Server/​Transport/​TransportInterface.php Documents the revised response contract.
src/​Server/​Transport/​StreamableHttpTransport.php Collects direct responses for HTTP output.
src/​Server/​Transport/​InlineResponseTransportInterface.php Removes the obsolete marker interface.
tests/​Unit/​Fixtures/​RecordingTransport.php Adds a response-recording test transport.
tests/​Unit/​Server/​ProtocolTest.php Updates protocol tests for direct sending.
tests/​Unit/​Server/​Transport/​StreamableHttpTransportTest.php Renames tests to match new terminology.
CHANGELOG.md Documents behavior and compatibility changes.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Server/Protocol.php
Comment thread src/Server/Transport/TransportInterface.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A non-throwing session-save failure can still attach a fiber whose pending request was not persisted.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

Comment thread src/Server/Protocol.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Session-save failures can remain silent or persist orphaned suspended requests during a retry.

1 open finding
1 resolved since last review

🧠 Review effort: Balanced

Comment thread src/Server/Protocol.php
Comment on lines +358 to +362
// The transport resumes the fiber from what the session holds: it must
// not get the fiber if the request the fiber awaits was not stored.
if (!$session->save()) {
throw new RuntimeException('Failed to save the session of a suspended request.');
}
@chr-hertel
chr-hertel merged commit 62daacc into modelcontextprotocol:main Oct 10, 2026
28 checks passed
@chr-hertel
chr-hertel deleted the inline-responses-follow-up branch October 10, 2026 01:11
@chr-hertel chr-hertel added the breaking change Breaking the Backwards Compatibility Promise label Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Breaking the Backwards Compatibility Promise

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants